package cn.starrysky.hrm.client;

import cn.starrysky.hrm.docment.CourseDoc;
import cn.starrysky.hrm.query.CourseDocQuery;
import cn.starrysky.hrm.util.AjaxResult;
import cn.starrysky.hrm.util.PageList;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class CourseSearchFallbackFactory implements FallbackFactory<CourseSearchClient> {
    @Override
    public CourseSearchClient create(Throwable cause) {
        return new CourseSearchClient() {
            @Override
            public AjaxResult addOrUpdate(CourseDoc courseDoc) {
                return AjaxResult.me().setSuccess(false).setMessage("上线添加索引库失败！");
            }

            @Override
            public AjaxResult delete(Long id) {
                return AjaxResult.me().setSuccess(false).setMessage("下线删除索引库信息失败！");
            }

            @Override
            public PageList<CourseDoc> queryCourses(CourseDocQuery docQuery) {
                throw  new RuntimeException("查询索引库失败") ;
            }
        };
    }
}
